home *** CD-ROM | disk | FTP | other *** search
- on keyDown
- global keyEditOK, fieldSpec
- if keyEditOK = 0 then
- exit
- end if
- case the frameLabel of
- "Create":
- set theField to "FieldEntry"
- set maxChars to 10
- set validChars to "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890_"
- set valid1stChars to "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
- end case
- if (the key = ENTER) or (the key = RETURN) then
- if field theField <> "_" then
- case the frameLabel of
- "Create":
- doCreateOK()
- end case
- end if
- else
- if the key = BACKSPACE then
- set numChars to the number of chars in field theField
- if numChars > 1 then
- if numChars > 2 then
- put char 1 to numChars - 2 of field theField & "_" into field theField
- else
- put "_" into field theField
- end if
- end if
- else
- set numChars to the number of chars in field theField
- if numChars <= maxChars then
- if numChars = 1 then
- if valid1stChars contains the key then
- put toupperC(the key) & "_" into field theField
- end if
- else
- if validChars contains the key then
- put char 1 to numChars - 1 of field theField & toupperC(the key) & "_" into field theField
- end if
- end if
- end if
- end if
- end if
- end
-
- on toupperC theChar
- if (charToNum(theChar) >= 97) and (charToNum(theChar) <= 122) then
- return numToChar(charToNum(theChar) - 32)
- else
- return theChar
- end if
- end
-